#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
	void reverse_all(char* str, int len)
	{
		for (int i = 0; i < len / 2; i++)
		{
			char temp = str[i];
			str[i] = str[len - i - 1];
			str[len - i - 1] = temp;
		}
	}
	void reverse_word(char* str, int len)
	{
		int temp = 0;
		int i = 0;
		while (i < len)
		{
			int temp = 0;
			while (str[i] != ' '&& i < len)
			{
				temp++;
				i++;
			}
			int end = i - 1;
			for (int begin = i - temp; begin < (2*i-temp)/2; begin++)
			{
				char t = str[begin];
				str[begin] = str[end];
				str[end] = t;
				end--;
			}
			i++;
		}
	}
	int main()
	{
		char str[100] = { 0 };
		int len = 0;
		char c = 0;
		gets(str);
		len = strlen(str);
		reverse_all(str, len);
		reverse_word(str, len);
		printf("%s", str);
		return 0;
	}